package com.fxcharts.widget.linechart.ext;
import com.fxcharts.widget.linechart.*;
import javafx.scene.shape.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.text.*;
import javafx.scene.effect.*;


/**
 * @author Aliaksandr_Spichakou
 */
public class ImgPointLineChart extends ExLineChart
{
    public-init var imageUrl:String;         
    override function getMarkerPoint(serial:ExLineSeries, x:Number,y:Number, point:Point):Node[]
    {                        
        var popUpLabel:Node;
        if(showPointTooltip)
        {          
          popUpLabel=getPointLabel(point,x+2*circleRadius,y-2*circleRadius);
          if(alwaysShowTooltip!=true)
         {
         	popUpLabel.opacity = 0;
         }   
        }               
        var image=Image {                           
                url: imageUrl                
                }                
        var imageView:ImageView = ImageView{
            translateX: x - image.width/2
            translateY: y - image.height/2
            image: image
            effect: DropShadow { offsetY: 4 }
            onMouseMoved: function( 
				            e: MouseEvent ):Void {
					                			if(showPointTooltip)
					                        	{
					                               popUpLabel.opacity = 1;                                 					                               					                               
					                        	}                           							   
					                        	point.tUp.playFromStart();                                                   
				                            }
  		    onMouseExited: function( e: MouseEvent ):Void {
                if(alwaysShowTooltip!=true)
                {
                	popUpLabel.opacity = 0;
                }
                point.tUp.pause();  
           }
        }              
        if(showPointTooltip)
        {
        	return [imageView,popUpLabel];	        
        }  
        return [imageView,Group{}];
    }    
}